home *** CD-ROM | disk | FTP | other *** search
/ Developer Helper 1: Phil & Dave's Excellent CD / Excellent CD HFS.raw / Moof / Goodies / HyperCard Goodies / Serial Toolkit / Source Code / killSPort.p < prev    next >
Text File  |  1988-11-18  |  2KB  |  75 lines

  1. (*
  2.     killSPort in/out/both -- Kill I/O on the current serial port. If the parameter is "in", then kill
  3.         the input; if the parameter is "out" then kill the output; otherwise kill both.
  4.  
  5.     To compile and link this file using Macintosh Programmer's Workshop,
  6.  
  7.         pascal -w killSPort.p
  8.         link -m ENTRYPOINT -o HyperCommands -rt XCMD=7032 -sn Main=killSPort ∂
  9.             killSPort.p.o "{MPW}"Libraries:interface.o
  10.  
  11.     © Copyright 1987,88 by Apple Computer, Inc.
  12.  
  13.     Initial coding 9/87 by Harry R. Chesley.
  14. *)
  15.  
  16. {$R-}
  17.  
  18. {$S killSPort }     { Segment name must be the same as the command name. }
  19.  
  20. unit DummyUnit;
  21.  
  22. interface
  23.  
  24. uses MemTypes, QuickDraw, OSIntf, HyperXCmd;
  25.  
  26. procedure EntryPoint(paramPtr: XCmdPtr);
  27.     
  28. implementation
  29.  
  30. type
  31.  
  32. Str31 = String[31];
  33.  
  34. procedure killSPort(paramPtr: XCmdPtr); forward;
  35.  
  36. procedure EntryPoint(paramPtr: XCmdPtr);
  37.  
  38.     begin
  39.         killSPort(paramPtr);
  40.     end;
  41.  
  42. procedure killSPort(paramPtr: XCmdPtr);
  43.  
  44.     var inOutBoth: Str255;
  45.  
  46.     {$I XCmdGlue.inc}
  47.  
  48.     procedure Fail(errMsg: Str255); { set theResult and quit }
  49.         begin
  50.             paramPtr^.returnValue := PasToZero(errMsg);
  51.             exit(killSPort);
  52.         end;
  53.  
  54.     {$I SPortUtil.inc}
  55.  
  56.     begin
  57.         if paramPtr^.paramCount <> 1 then Fail('parameter count is not 1');
  58.  
  59.         SetUpSPortGlobals;
  60.         EnsureOpenPort;
  61.  
  62.         GetStrParm(1,inOutBoth);
  63.  
  64.         if StringEqual(inOutBoth,'in') or StringEqual(inOutBoth,'both') then
  65.             begin
  66.                 if KillIO(ThisSPort.portInDev) <> noErr then Fail('KillIO failed');
  67.             end;
  68.         if StringEqual(inOutBoth,'out') or StringEqual(inOutBoth,'both') then
  69.             begin
  70.                 if KillIO(ThisSPort.portOutDev) <> noErr then Fail('KillIO failed');
  71.             end;
  72.     end;
  73.  
  74. end.
  75.